//
//  NKMainNavigation.m
//  NewKY
//
//  Created by Dee on 2016/11/13.
//  Copyright © 2016年 Dee. All rights reserved.
//

#import "NKMainNavigation.h"
#import "NKHomeViewController.h"
#import "UIViewController+LMSideBarController.h"
@interface NKMainNavigation ()

@end

@implementation NKMainNavigation


/**
 显示 Home(特殊) 控制器,包含 Tabbar
 */
- (void)showHomeViewController
{
    
    UITabBarController *tabbar = [UITabBarController new];
    NKHomeViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"NKHomeViewController"];
    vc.tabBarItem.image = [UIImage imageNamed:@"tab_normal_1"];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:@"tab_normal_1_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.title = @"首页";
    
    
    UIViewController *vc1 = [UIViewController new];
    vc1.tabBarItem.image = [UIImage imageNamed:@"tab_normal_2"];
    vc1.tabBarItem.selectedImage = [[UIImage imageNamed:@"tab_normal_2_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc1.title = @"发现";
    UINavigationController *nav1 = [UINavigationController new];
    [nav1.navigationBar setTintColor:[UIColor blackColor]];
    [nav1 setViewControllers:@[vc1]];
    nav1.title = @"发现";
    
    UIViewController *vc2 = [UIViewController new];
    vc2.tabBarItem.image = [UIImage imageNamed:@"tab_normal_3"];
    vc2.tabBarItem.selectedImage = [[UIImage imageNamed:@"tab_normal_3_selected"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc2.title = @"健康";
    UINavigationController *nav2 = [UINavigationController new];
    [nav2.navigationBar setTintColor:[UIColor blackColor]];
    [nav2 setViewControllers:@[vc2]];
    nav1.title = @"健康";

    
    tabbar.viewControllers = @[vc,vc1,vc2];
    tabbar.title = @"首页";
    tabbar.tabBar.tintColor = [UIColor colorWithHexString:@"51B4B1"];
    
    [self addLeftItem:tabbar];
    
    [self setViewControllers:@[tabbar] animated:YES];
}


/**
 显示一个控制器

 @param className  vc 类名
 @param title vc 标题
 */
-(void)showOtherViewController:(NSString *)className title:(NSString *)title{
    
    UIViewController *vc = [NSClassFromString(className) new];
    vc.title = title;
    [self addLeftItem:vc];
    [self setViewControllers:@[vc] animated:YES];
    
}



/**
 添加左侧按钮

 @param vc 控制器
 */
-(void)addLeftItem:(UIViewController *)vc{
    UIImage *buttonImage = [UIImage imageNamed:@"batch_menu"];
    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [aButton setImage:buttonImage forState:UIControlStateNormal];
    aButton.frame = CGRectMake(0.0,0.0,buttonImage.size.width,buttonImage.size.height);
    [aButton addTarget:self action:@selector(aSelector) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:aButton];
    vc.navigationItem.leftBarButtonItem = backButton;
    
}


-(void)aSelector{
    [self.sideBarController showMenuViewControllerInDirection:LMSideBarControllerDirectionLeft];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.tintColor = [UIColor whiteColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
